/*
 * Copyright (c) 2010 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.google.api.data.calendar.v2.model;

import com.google.api.client.util.Key;

/**
 * Represents a base GData Access Rule Entry.
 * 
 * @author Alain Vongsouvanh
 */
public class AccessControl {

  /**
   * Represents a base Scope Access Rule Entry.
   * 
   * @author Alain Vongsouvanh
   */
  public static class Scope {
    /**
     * Indicates that this access rule applies to an individual. The value
     * attribute is an email address.
     */
    public static final String TYPE_USER = "user";
    /**
     * Available only in Google Apps For Your Domain. Indicates that this access
     * rule applies to all users with email addresses in your domain, which
     * allows you to (for example) create calendars that are shared with
     * everyone in your domain. The value attribute should contain your domain
     * name.
     */
    public static final String TYPE_DOMAIN = "domain";
    /**
     * Indicates that this access rule applies to all users. There is no value
     * attribute.
     */
    public static final String TYPE_DEFAULT = "default";

    @Key("@type")
    public String type;

    @Key("@value")
    public String value;
  }

  /** The specified users have no rights. */
  public static final String ROLE_NONE = "none";
  /** The specified users have read-only access to the calendar. */
  public static final String ROLE_READ = "read";
  /**
   * The specified users can see only the free/busy information on the calendar,
   * not the details of events.
   */
  public static final String ROLE_FREEBUSY = "freebusy";
  /**
   * The specified users have full edit access to the calendar, except that they
   * can't change the calendar's access control settings.
   */
  public static final String ROLE_EDITOR = "editor";
  /** The specified users have full owner access to the calendar. */
  public static final String ROLE_OWNER = "owner";
  /**
   * Available only in Google Apps For Your Domain. The specified users have
   * administrator access to the calendar server.
   */
  public static final String ROLE_ROOT = "root";

  /**
   * Defines which set of users are governed by the rule that contains this
   * element.
   */
  @Key("gAcl:scope")
  public Scope scope;

  /**
   * Defines an access level that applies to all users specified in the
   * associated {@link #scope}. Possible values are {@link #ROLE_EDITOR},
   * {@link #ROLE_FREEBUSY}, {@link #ROLE_NONE}, {@link #ROLE_OWNER},
   * {@link #ROLE_READ} and {@link #ROLE_ROOT}
   * 
   */
  @Key("gAcl:role@value")
  public String role;
}
